package com.stu.moudle;

import io.fabric8.kubernetes.api.model.Namespace;
import io.fabric8.kubernetes.api.model.Service;
import io.fabric8.kubernetes.api.model.ServiceList;
import io.fabric8.kubernetes.client.Config;
import io.fabric8.kubernetes.client.ConfigBuilder;
import io.fabric8.kubernetes.client.DefaultKubernetesClient;
import io.fabric8.kubernetes.client.KubernetesClient;
import org.junit.Test;

import java.util.List;

/**
 * @projectName: learn_used_code
 * @packageName: com.stu.moudle
 * @className: com.stu.moudle-> DockerApiTest
 * @createDate: 2021-10-20 14:09
 * @author: ZhangSheng
 * @version: 1.0
 * @description:
 */
public class DockerApiTest {


    @Test
    public void test1(){
        Config config = new ConfigBuilder().withMasterUrl("http://10.253.156.130:6443").build();
        KubernetesClient client = new DefaultKubernetesClient(config);
        Namespace namespace = client.namespaces().withName("ingress-nginx").get();
        ServiceList serviceList = client.services().inNamespace("ingress-nginx").list();
        List<Service> items = serviceList.getItems();
        for (Service item : items) {
            System.out.println(item.getAdditionalProperties());
            System.out.println(item.getApiVersion());
            System.out.println(item.getMetadata());
            System.out.println(item.getKind());
            System.out.println(item.getSpec());
        }
    }

    @Test
    public void test2(){
        Config config = new ConfigBuilder().withMasterUrl("http://10.253.156.130:6443").build();
        KubernetesClient client = new DefaultKubernetesClient(config);
        ServiceList list = client.services().list();
    }


}
